package com.SSII.otrapru;

import java.util.ArrayList;








import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;

public class ItemListAdapter extends BaseAdapter{


	private Context context;
	int resource;
    private ArrayList<PalabraTodo> items;
    private ArrayList<Integer> indices;
    
    public ItemListAdapter(Context context, int resource, ArrayList<PalabraTodo> items) {
		super();
		this.context=context;
		this.resource=resource;
		this.items=items;
		int tamA=items.size();
		indices = new ArrayList<Integer>();
		for(int i=0; i<tamA; i++){
			indices.add(i, 0);
		}
	}	
	
    public int getIndicesPos(int index){
    	return indices.get(index);
    }
    public void setIndicesPos(int index,int valor){
    	indices.set(index,valor);
    }
    
    @Override
	public View getView(int position, View convertView, ViewGroup parent) {
    		int imgn=indices.get(position);	
    		LayoutInflater inflater = (LayoutInflater) LayoutInflater.from(context);
            View rowView = inflater.inflate(R.layout.listview_item, parent, false);
            ImageView imageView = (ImageView) rowView.findViewById(R.id.ivItem);
            imageView.setBackgroundColor(items.get(position).getColor());
            imageView.setImageBitmap(items.get(position).getBitmap());

            return rowView;
   }

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}
}
	 

